Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UnitarySynthesis for 3+ qubits when compiled for a backend #13591

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Dec 20, 2024

Summary

When encountering a 3+ qubit UnitaryGate, UnitarySynthesis currently replaces the whole dag with the definition of the block instead of appending it, see

Details and comments

This also leads to #13586 because the qubit/clbit interners are overwritten, but maybe more importantly this can lead to issues when multiple 3-qubit blocks are present in the circuit. E.g. running

import numpy as np
from qiskit.quantum_info import Operator
from qiskit.circuit.library import UnitaryGate
from qiskit import QuantumCircuit, transpile
from qiskit_ibm_runtime.fake_provider import FakeSherbrooke

backend = FakeSherbrooke()

x = QuantumCircuit(3)
x.x(2)
x_mat = Operator(x)

qc = QuantumCircuit(3, 1)
qc.unitary(x_mat, range(3))
qc.unitary(np.eye(2 ** 3), range(3))

tqc = transpile(qc, backend, optimization_level=0)
print(tqc.count_ops())

produces an empty circuit, since the last block implements the identity.

Some additional tests, such as the precise case of #13586 and a series of 3q UnitaryGates, should be added.

@Cryoris Cryoris added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog Rust This PR or issue is related to Rust code in the repository labels Dec 20, 2024
@Cryoris Cryoris added this to the 1.3.2 milestone Dec 20, 2024
@Cryoris Cryoris requested a review from a team as a code owner December 20, 2024 16:12
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@coveralls
Copy link

Pull Request Test Coverage Report for Build 12434705540

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 23 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.01%) to 88.941%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 5 91.73%
crates/qasm2/src/parse.rs 18 96.23%
Totals Coverage Status
Change from base Build 12420636821: -0.01%
Covered Lines: 79419
Relevant Lines: 89294

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog Rust This PR or issue is related to Rust code in the repository stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rust exeception raised when transpiling PaulEvolutionGate with measurements against backend
3 participants